﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using CNotebook;
using CNotebook.Sales;

namespace NotebookS2
{
    public partial class BRW_DELIVERIES : RibbonForm
    {
        public BRW_DELIVERIES()
        {
            InitializeComponent();
        }
        public string ConnectionString { get; set; }
        public string ActiveUserID { get; set; }
        public string Department { get; set; }
        private void btnPreview_Click(object sender, EventArgs e)
        {
            try
            {
                DeliveryManager oManager = new DeliveryManager();

                oManager.ConnectionString = this.ConnectionString;
                oManager.Open();

                DataTable _table = new DataTable();
                if (cboSearch.SelectedIndex == 0)
                {
                    _table = oManager.GetDRStatusByPostingDate((DateTime)dtFROM.EditValue, (DateTime)dtTO.EditValue, chkDraft.Checked, chkPosted.Checked, chkOpen.Checked, chkClosed.Checked);
                }
                else
                {
                    _table = oManager.GetDRStatusByInvoiceDate((DateTime)dtFROM.EditValue, (DateTime)dtTO.EditValue, chkDraft.Checked, chkPosted.Checked, chkOpen.Checked, chkClosed.Checked);
                }

                oManager.Close();

                gridControl1.DataSource = _table;
                gridControl1.Refresh();
                gridView1.ExpandAllGroups();

            }
            catch
            {
            }
        }


        public void PrintPreview()
        {
            if (!gridControl1.IsPrintingAvailable)
            {
                MessageBox.Show("The 'DevExpress.XtraPrinting' Library is not found", "Error");
                return;
            }
            // Opens the Preview window. 
            gridControl1.ShowPrintPreview();
        }
        private void BRW_DELIVERIES_Load(object sender, EventArgs e)
        {
            cboSearch.SelectedIndex = 0;
            dtFROM.EditValue = System.DateTime.Now;
            dtTO.EditValue = System.DateTime.Now;
        }
    }
}
